package edu.zut.cs.software.example.product.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import edu.zut.cs.software.example.market.dao.ProductDao;
import edu.zut.cs.software.example.market.domain.Product;
import edu.zut.cs.software.example.product.service.ProductManager;
import edu.zut.cs.software.example.service.impl.GenericManagerImpl;


/**
 * @author The Geng
 *
 */
@Service
public class ProductManagerImpl extends GenericManagerImpl<Product, Long> implements ProductManager {
	
	ProductDao productDao;

	@Autowired
	public void setProductDao(ProductDao productDao) {
		this.productDao = productDao;
		this.dao = this.productDao;
	}
	/**
	 * 
	 * get product by id
	 * @param id
	 * @return Product
	 */
	@Override
	public Product getUpdateProService(int id) {
		return productDao.getUpdateProduct(id);
	}
	/**
	 * 
	 * Reedit product information
	 * @param Product
	 * @return Product
	 */
	@Override
	public int editProInfoService(Product product) {
		Long ID=product.getId();
		String name=product.getName();
		String price=product.getPrice();
		String poster=product.getPoster();
		String description=product.getDescription();
		String sort=product.getSort();
		Long studentid=product.getStudentid();
		
		return productDao.editProduct(name,price,poster,description,sort,studentid,ID);
	}

}
